<?php $this->fetch('public/head') ?>
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class="layui-this">信息列表</li>
        <li onclick="update_sess()">更新缓存</li>
    </ul>
    <div class="layui-tab-content">
        <hr>

        <div class="layui-tab-item layui-show">
            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="200">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th>id</th>
                    <th>部门名称</th>
                    <th>部门领导</th>
                    <th>分管领导</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($list['data'] as $item) {?>
                <tr>
                    <td><?php echo $item['id']?></td>
                    <td><?php echo str_repeat('-',$item['level']+1).$item['name']?></td>
                    <?php $item['info']['leader_user_list'] =json_decode($item['info']['leader_user_list'],true)?>
                    <td>
                        <?php foreach ($item['info']['leader_user_list'] as $v){
                            echo $userlist[$v].'|';
                        }?>
                    </td>
                    <?php $item['info']['class_user_list'] =json_decode($item['info']['class_user_list'],true)?>
                    <td>
                        <?php foreach ($item['info']['class_user_list'] as $v){
                            echo $userlist[$v].'|';
                        }?>
                    </td>
                    <td>
                        <a href="<?php echo url('put_leader',['id'=>$item['id'],'type'=>1])?>" class="layui-btn">部门领导</a>
                        <a href="<?php echo url('put_leader',['id'=>$item['id'],'type'=>2])?>" class="layui-btn">分管领导</a></td>
                </tr>
                <?php }?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<?php $this->fetch('public/script') ?>
<script>
    function update_sess() {
        layer.msg('更新中...',{time:60000,icon: 16,shade: 0.3});
        $.ajax({
            url:"<?php echo url('user/get_userlist')?>",
            success:function (data) {
                layer.closeAll();
                layer.msg(data.msg);
                setTimeout(function () {
                    location.reload();
                },1000)
            }
        })
    }
</script>